package com.atguigu.guli.edu.controller;

import java.util.Arrays;
import java.util.Map;

import com.atguigu.common_utils.utils.PageUtils;
import com.atguigu.common_utils.utils.R;
import com.atguigu.guli.edu.entity.Chapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.atguigu.guli.edu.service.EduChapterService;



@RestController
@RequestMapping("edu/educhapter")
public class EduChapterController {

    @Autowired
    private EduChapterService eduChapterService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("edu:educhapter:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = eduChapterService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("edu:educhapter:info")
    public R info(@PathVariable("id") String id){
        Chapter eduChapter = eduChapterService.getById(id);

        return R.ok().put("eduChapter", eduChapter);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("edu:educhapter:save")
    public R save(@RequestBody Chapter eduChapter){
		eduChapterService.save(eduChapter);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("edu:educhapter:update")
    public R update(@RequestBody Chapter eduChapter){
		eduChapterService.updateById(eduChapter);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("edu:educhapter:delete")
    public R delete(@RequestBody String[] ids){
		eduChapterService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
